#include <stdlib.h>
#include <ucontext.h>
#define STACK_SIZE 64*1024
#ifndef THREAD
#define THREAD
typedef enum{/*PROPER_END, ERROR_END,*/ENDED, SLEEPING,RUNNING } thread_status;
struct thread {
	thread_status status;
	ucontext_t context;
	struct timeval* execution_time;
	unsigned int thread_id;
	void* retval;
};
typedef struct thread* thread_t;


extern thread_t thread_self(void);
extern int thread_create(thread_t* newthread, void *(*func)(void *), void *funcarg);
extern int thread_yield();
extern int thread_join(thread_t thread, void **retval);
extern void thread_exit(void *retval) __attribute__ ((__noreturn__));
void thread_init();
#endif//THREAD
